#include <LogStream.h>

namespace AsyncLogger {
	LogStream& LogStream::operator<<(const std::string& logline)
	{
		if (!logline.empty()) {
			buffer_.append(logline.c_str(), logline.size());
		}
		return *this;
	}

	LogStream& LogStream::operator<<(const char* logline)
	{
		buffer_.append(logline, strlen(logline));
		return *this;
	}

	//LogStream& LogStream::operator<<(const char* logline, len)
	//{
	//	buffer_.append(logline, len);
	//	return *this;
	//}

	LogStream& LogStream::operator<<(const unsigned char* logline)
	{
		*this << (reinterpret_cast<const char*>(logline));
		return *this;
	}

	LogStream& LogStream::operator<<(bool logline)
	{
		*this << (logline ? "true" : "false");
		return *this;
	}

	LogStream& LogStream::operator<<(char logline)
	{
		buffer_.append(&logline, 1);
		return *this;
	}

	LogStream& LogStream::operator<<(long logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(unsigned long logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(long long logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(unsigned long long logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(int logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(unsigned int logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(double logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}

	LogStream& LogStream::operator<<(float logline)
	{
		std::string sNum = numToString(logline);
		buffer_.append(sNum.c_str(), sNum.size());
		return *this;
	}
}